/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entitybean;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "media_like", catalog = "OnlineShopFourDVD", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "MediaLike.findAll", query = "SELECT m FROM MediaLike m"),
    @NamedQuery(name = "MediaLike.findByMediaId", query = "SELECT m FROM MediaLike m WHERE m.mediaLikePK.mediaId = :mediaId"),
    @NamedQuery(name = "MediaLike.findByUserId", query = "SELECT m FROM MediaLike m WHERE m.mediaLikePK.userId = :userId"),
    @NamedQuery(name = "MediaLike.findByLikeDate", query = "SELECT m FROM MediaLike m WHERE m.likeDate = :likeDate")})
public class MediaLike implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MediaLikePK mediaLikePK;
    @Column(name = "like_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date likeDate;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Users users;
    @JoinColumn(name = "media_id", referencedColumnName = "media_id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Media media;

    public MediaLike() {
    }

    public MediaLike(MediaLikePK mediaLikePK) {
        this.mediaLikePK = mediaLikePK;
    }

    public MediaLike(int mediaId, int userId) {
        this.mediaLikePK = new MediaLikePK(mediaId, userId);
    }

    public MediaLikePK getMediaLikePK() {
        return mediaLikePK;
    }

    public void setMediaLikePK(MediaLikePK mediaLikePK) {
        this.mediaLikePK = mediaLikePK;
    }

    public Date getLikeDate() {
        return likeDate;
    }

    public void setLikeDate(Date likeDate) {
        this.likeDate = likeDate;
    }

    public Users getUsers() {
        return users;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    public Media getMedia() {
        return media;
    }

    public void setMedia(Media media) {
        this.media = media;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mediaLikePK != null ? mediaLikePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MediaLike)) {
            return false;
        }
        MediaLike other = (MediaLike) object;
        if ((this.mediaLikePK == null && other.mediaLikePK != null) || (this.mediaLikePK != null && !this.mediaLikePK.equals(other.mediaLikePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entitybean.MediaLike[mediaLikePK=" + mediaLikePK + "]";
    }

}
